package com.yay.mashiro.yayclient.ui.clickgui.panel;

import java.awt.Color;
import java.util.ArrayList;
import java.util.List;

import com.yay.mashiro.yayclient.Yay;
import com.yay.mashiro.yayclient.module.Category;
import com.yay.mashiro.yayclient.module.modules.render.ClickGui;
import com.yay.mashiro.yayclient.ui.clickgui.font.HanabiFonts;
import com.yay.mashiro.yayclient.ui.clickgui.font.UnicodeFontRenderer;

import ClassSub.Class246;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.ScaledResolution;

public class SideBar {
	Minecraft mc = Minecraft.getMinecraft();
    ScaledResolution sr;
    int length;
    public float animationY;
    public List<CategoryPanel> button = new ArrayList<CategoryPanel>();

    public SideBar() {
        this.sr = new ScaledResolution(this.mc);
        this.length = (int)((double)this.sr.getScaledWidth() * 0.155);
        for (int i = 0; i < Category.values().length; ++i) {
//            LeftPanel LeftPanel = new LeftPanel(this, this.length / 2, (float)this.sr.getScaledHeight() * 0.342f + (float)((i + 1) * this.sr.getScaledHeight()) * 0.078f, this.length / 2, Category.values()[i].toString(), this.sr);
            CategoryPanel LeftPanel = new CategoryPanel(this.length / 2, this.length / 2, (float)this.sr.getScaledHeight() * 0.342f + (float)((i + 1) * this.sr.getScaledHeight()) * 0.078f, Category.values()[i].toString(), this.sr, this);
            LeftPanel.active = false;
            this.button.add(LeftPanel);
        }
        this.button.get((int)0).active = true;
    }

    public void draw() {
        this.sr = new ScaledResolution(this.mc);
        Class246.drawRect(0.0f, 0.0f, this.length, this.sr.getScaledHeight(), ClickGui.theme.isCurrentMode("Light") ? -1118482 : new Color(22, 22, 22).getRGB());
        Class246.drawRect(this.length, 0.0f, this.length + 2, this.sr.getScaledHeight(), ClickGui.theme.isCurrentMode("Light") ? new Color(-14848033).brighter().getRGB() : new Color(47, 116, 253).getRGB());
        CategoryPanel LeftPanel = null;
        this.length = (int)((double)this.sr.getScaledWidth() * 0.155);
        int n = 0;
        for (CategoryPanel LeftPanel2 : this.button) {
            LeftPanel2.x = this.length / 2;
            LeftPanel2.y = (float)this.sr.getScaledHeight() * 0.342f + (float)((n + 1) * this.sr.getScaledHeight()) * 0.078f - 40.0f;
            LeftPanel2.radius = this.length / 2;
            ++n;
            if (!LeftPanel2.active.booleanValue()) continue;
            LeftPanel = LeftPanel2;
        }
        this.animationY = (float)Class246.getAnimationState(this.animationY, LeftPanel.y, Math.max(10.0, (double)(Math.abs(this.animationY - LeftPanel.y) * 50.0f) * 0.3));
        //FIXME problem
//        Class246.drawRoundedRect((int)LeftPanel.x - 50, (int)this.animationY - 15, (int)LeftPanel.x + 50, (int)this.animationY + 18, 15.0f, ClickGui.theme.isCurrentMode("Light") ? new Color(-14848033).brighter().getRGB() : new Color(47, 116, 253).getRGB());
        int yOffset = (int)LeftPanel.y;
        Class246.drawRoundedRect(24 , yOffset - 18.0f, 124, 20 + yOffset, 15.0f, ClickGui.theme.isCurrentMode("Light") ? new Color(-14848033).brighter().getRGB() : new Color(47, 116, 253).getRGB());
        for (CategoryPanel LeftPanel2 : this.button) {
            LeftPanel2.drawOther();
        }
        UnicodeFontRenderer object = Yay.getFontManager().icon50;
        if (this.sr.getScaledHeight() < 330) {
            object = Yay.getFontManager().icon50;
        } else if (this.sr.getScaledHeight() < 370) {
            object = Yay.getFontManager().icon70;
        } else if (this.sr.getScaledHeight() < 450) {
            object = Yay.getFontManager().icon100;
        } else if (this.sr.getScaledHeight() < 550) {
            object = Yay.getFontManager().icon130;
        }
        object.drawCenteredString(HanabiFonts.ICON_HANABI_LOGO, (int)((double)this.length / 2.1), (int)((double)this.sr.getScaledHeight() * 0.11), ClickGui.theme.isCurrentMode("Light") ? new Color(-14848033).brighter().getRGB() : new Color(47, 116, 253).getRGB());
    }

    public void onMouseClick(int n, int n2) {
        for (CategoryPanel LeftPanel : this.button) {
            if (!LeftPanel.isPressed(n, n2)) continue;
            LeftPanel.onPress();
            WindowPanel.wheelStateMod = 0;
        }
    }
}
